		var EmbedderObj = new Class( {
			options: {
				panelID:'mioEmbeder',
				instanceid: '1',
				tempid   : '90X',
				handlerPath:'',
				currentEdit:''
			},
			initialize: function(options) {
				this.options.panelID = options.panelID;			
				this.options.instanceid = options.instanceid;
				this.options.tempid = options.tempid;			
				if(options.handlerPath)					
					this.options.handlerPath = options.handlerPath;												
					
				//init leftAre:
				var addB = $(this.options.panelID+'_addbtm') ;
				var delB = $(this.options.panelID+'_delbtm') ;				
				var saveB = $(this.options.panelID+'_savebtm') ;								
				var seleB = $(this.options.panelID+'_lister') ;	
				document.write(this.options.handlerPath);											
				var mioFF = this;	
				if( addB ) {
					addB.addEvent('click',function(e) {	
						evt = new Event(e);evt.stop();					
						//clear one e 
						var title = $(mioFF.options.panelID+'_inputTitle');
						var emb = $(mioFF.options.panelID+'_inputEmb');						
						if( title ) title.value = '';
						if( emb ) emb.value = '';
						mioFF.options.currentEdit = 'new';						
					});
				}				
				if( delB ) {
					delB.addEvent('click',function(e) {	
						evt = new Event(e);evt.stop();
						var selo = -1;
						for(var i =0; i<seleB.options.length; i++) {
							if(seleB.options[i].selected.toString()=='true') {
								selo = i;break;
							}
						}
						if(selo==-1) {
							return;
						}
						if( confirm('sei sicuro di voler eliminare la scheda: ' + seleB.options[selo].text)) {
							//chiamata ajax per eliminazione scheda...
							mioFF.delEmbed(selo);
						}
					});
				}	
				if( saveB ) {
					saveB.addEvent('click',function(e) {	
						evt = new Event(e);evt.stop();
						//clear one e 
						if(mioFF.options.currentEdit== null ||
						   mioFF.options.currentEdit.toString()=='') {
							return;   
						}
						var title = $(mioFF.options.panelID+'_inputTitle');
						var emb = $(mioFF.options.panelID+'_inputEmb');						
						var _title = (title?title.value:'');
						var _emb   = (emb?emb.value:'');
						if(_title=='' || _emb=='') {
							alert('impossibile Salvare elemento...');
							return;
						}
						if(mioFF.options.currentEdit=='new') {
							//salva nuovo
							mioFF.saveEmbed(_title,_emb);
						} else {
							//aggiorna esistente.
							mioFF.updEmbed(_title,_emb);
						}								
						//alert('sto per salvare: ' +  mioFF.options.currentEdit.toString());
						//chiamata ajax
					});
				}	
				if( seleB ) {
					seleB.addEvent('click',function(e) {	
						evt = new Event(e);evt.stop();
						//clear one e 
						if(this.value==null || this.value.toString()=='') return;
						mioFF.loadScheme(this.value);
					});
				}					
				this.loadEmbeds();
			}, 
			
			loadScheme : function(curID) {
				this.options.currentEdit = curID;
				//qui dovrei fare l'xhr che si carica i valori...
				var titleB = $(this.options.panelID+'_inputTitle') ;	
				if(titleB == null) return;
				var embB = $(this.options.panelID+'_inputEmb') ;	
				if(embB == null) return;
				var myXhr = new XHR({async: true, method: 'get', onSuccess: function(text,xml) {
						if(text==null) {alert('no load'); return; }
						if(xml==null) {alert('xml no load'); return; }						
						var cXml;
						if (window.ActiveXObject)
						{
							var xmlObj=new ActiveXObject("Microsoft.XMLDOM");
							xmlObj.async="false";
							xmlObj.loadXML(text);
							if(xmlObj.documentElement == null) {	alert('sono nullo'); return; }
							cXml = xmlObj.documentElement;		
						} else {
							cXml = xml.documentElement;
						}						
						if(cXml == null) {
							titleB.value = "";
							embB.value   = "";
							alert('unable load content.');
						}
						for(var i = 0 ; i<cXml.childNodes.length; i++ ) {
							if (cXml.childNodes[i].nodeType != 1) continue;
							if( cXml.childNodes[i].nodeName == 'label')
								titleB.value = cXml.childNodes[i].firstChild.nodeValue;
							if( cXml.childNodes[i].nodeName == 'embed')
								embB.value = cXml.childNodes[i].firstChild.nodeValue;
						}
				}
				});
				myXhr.send(this.options.handlerPath, 'op=emb_load&id='+curID);							
			}, 
			
			loadEmbeds : function() {
				var title = $(this.options.panelID+'_inputTitle');
				var emb = $(this.options.panelID+'_inputEmb');						
				title.value = '';
				emb.value = '';
				this.options.currentEdit='';
				if(this.options.instanceid==null || this.options.instanceid=='') return;
				var seleB = $(this.options.panelID+'_lister') ;	
				if(seleB == null) return;
				seleB.empty();
				var myXhr = new XHR({async: true, method: 'get', onSuccess: function(text,xml) {
						if(text==null) {alert('no load'); return; }
						if(xml==null) {alert('xml no load'); return; }						
						var cXml;
						if (window.ActiveXObject)
						{
							var xmlObj=new ActiveXObject("Microsoft.XMLDOM");
							xmlObj.async="false";
							xmlObj.loadXML(text);
							if(xmlObj.documentElement == null) {	alert('sono nullo' + text); return; }
							cXml = xmlObj.documentElement;		
						} else {
							cXml = xml.documentElement;
						}						
						if(cXml == null) {
							titleB.value = "";
							embB.value   = "";
							alert('unable load content.');
						}
						for(var i = 0 ; i<cXml.childNodes.length; i++ ) {
							if (cXml.childNodes[i].nodeType != 1) continue;
							if( cXml.childNodes[i].nodeName == 'dato') {
								var elem = cXml.childNodes[i];
								var label = "";
								var id_o    = "";
								for(var j=0; j<elem.childNodes.length;j++) {
									if (elem.childNodes[j].nodeType != 1) continue;
									if( elem.childNodes[j].nodeName == 'label')
										label = elem.childNodes[j].firstChild.nodeValue;
									if( elem.childNodes[j].nodeName == 'id')
										id_o = elem.childNodes[j].firstChild.nodeValue;
								}
								seleB.options[seleB.options.length] = new Option(label,id_o);
							}
						}
				}
				});
				myXhr.send(this.options.handlerPath, 'op=emb_list&id='+this.options.instanceid);							
			},
			updEmbed : function(title, embes) {
				//qui dovrei fare l'xhr che si carica i valori...
				Cookie.set('emb_title', title);
				Cookie.set('emb_value', embes);
				var myXhr = new XHR({async: true, method: 'get', onSuccess: function(text,xml) {
						if(text==null) {alert('no load'); return; }
						if(text.toString()=='1') {
							alert('ok salvato');
							mioFF.loadEmbeds();
						}

				}
				});
				myXhr.send(this.options.handlerPath, 'op=emb_upd&id='+this.options.currentEdit.toString());							
			},
			saveEmbed : function(title, embes) {
				//qui dovrei fare l'xhr che si carica i valori...
				Cookie.set('emb_title', title);
				Cookie.set('emb_value', embes);
				var mioFF = this;
				var myXhr = new XHR({async: true, method: 'get', onSuccess: function(text,xml) {
						if(text==null) {alert('no load'); return; }
						if(text=='1') {
							alert('ok salvato');
							mioFF.loadEmbeds();
						}
				}
				});
				myXhr.send(this.options.handlerPath, 'op=emb_save&id='+this.options.instanceid.toString());							
			},
			delEmbed : function(ide_del) {
				//qui dovrei fare l'xhr che si carica i valori...
				var mioFF = this;
				var myXhr = new XHR({async: true, method: 'get', onSuccess: function(text,xml) {
						if(text==null) {alert('no load'); return; }
						if(text=='1') {
							alert('Embeds Successfull deleted');
							mioFF.loadEmbeds();
						}
				}
				});
				myXhr.send(this.options.handlerPath, 'op=emb_del&id='+ide_del);							
			}						
		});
		EmbedderObj.implement(new Options, new Events);			
